<template>
  <div class="main">
    <div class="container">
      <div class="left-panel">
        <div class="overlay"></div>
        <div class="content">
          <h1>驾校考试系统</h1>
          <p class="slogan">安全 · 高效 · 专业</p>
          <div class="features">
            <div class="feature-item">
              <i class="icon">✓</i>
              <span>专业驾考培训</span>
            </div>
            <div class="feature-item">
              <i class="icon">✓</i>
              <span>模拟考试系统</span>
            </div>
            <div class="feature-item">
              <i class="icon">✓</i>
              <span>学习进度跟踪</span>
            </div>
          </div>
        </div>
      </div>

      <div class="right-panel">
        <Login v-if="showLogin" @toggleForm="toggleForm" />
        <Register v-else-if="showRegister" @toggleForm="toggleForm" />
        <ForgotPassword v-else-if="showForgotPassword" @toggleForm="toggleForm" />
        <ResetPassword
          v-else-if="showResetPassword"
          :username="username"
          @toggleForm="toggleForm"
        />
      </div>
    </div>
  </div>
</template>

<script>
import Login from '../components/Login.vue';
import Register from '../components/Register.vue';
import ForgotPassword from '../components/ForgotPassword.vue';
import ResetPassword from '../components/ResetPassword.vue';

export default {
  components: {
    Login,
    Register,
    ForgotPassword,
    ResetPassword,
  },
  data() {
    return {
      showLogin: true,
      showRegister: false,
      showForgotPassword: false,
      showResetPassword: false,
      username: '', // 用于保存账号信息
    };
  },
  methods: {
    toggleForm(form, username = '') {
      this.showLogin = form === 'login';
      this.showRegister = form === 'register';
      this.showForgotPassword = form === 'forgotPassword';
      this.showResetPassword = form === 'resetPassword';
      this.username = username; // 保存账号信息
    },
  },
};
</script>

<style>
:root {
  --primary-color: #2c7be5;
  --primary-hover: #1a68d1;
  --secondary-color: #45c1f3;
  --text-color: #333;
  --light-gray: #f8f9fa;
  --border-radius: 8px;
  --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.main {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 1;
  color: #635959;
  background-color: #f5f5f5; /* 添加背景色 */
}

.main::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("../assets/2.png");
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0.5;
  z-index: 1;
}

.container {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: row;
  width: 1000px;
  height: 520px;
  border-radius: 20px;
  overflow: hidden;
  justify-content: center;
  box-shadow: 0 0 25px 0 #ffff;
}

.left-panel {
  position: relative;
  width: 50%;
  background-size: cover;
  background-position: center;
  background: linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.5)), 
              url("steering-wheel.jpg") center/cover;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.content {
  position: relative;
  z-index: 2;
  color: white;
  padding: 40px;
  text-align: center;
  width: 100%;
}

.content h1 {
  font-size: 2.5rem;
  margin-bottom: 15px;
  font-weight: 600;
}

.slogan {
  font-size: 1.2rem;
  margin-bottom: 40px;
  opacity: 0.9;
}

.features {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 40px;
}

.feature-item {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.feature-item .icon {
  margin-right: 10px;
  background-color: var(--primary-color);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.right-panel {
  width: 50%;
  background-color: white;
  padding: 40px;
  border-radius: 0 20px 20px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.page {
  width: 100%;
}

.right-panel h2 {
  text-align: center;
  margin-bottom: 40px;
  font-size: 2rem;
  color: #45c1f3;
}

.input-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
}

.input-group label {
  margin-bottom: 5px;
  font-weight: bold;
  color: #333;
}

.input-group input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 1rem;
}

.checkbox-group {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
}

.checkbox-group label {
  margin-left: 10px;
  color: #333;
}

.login-button,
.register-button,
.forgot-password-button {
  width: 100%;
  padding: 10px;
  background-color: #45c1f3;
  border: none;
  border-radius: 5px;
  margin-top: 15px;
  color: white;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.3s ease;
}

.login-button:hover,
.register-button:hover,
.forgot-password-button:hover {
  background-color: #3aa8d8; /* 悬停效果 */
}

.links {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

.links a {
  color: #45c1f3;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.3s ease;
}

.links a:hover {
  color: #3aa8d8; /* 悬停效果 */
}
</style>